﻿using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Loger;
using Learun.Util;
using Learun.Util.SqlSugar;
using log4net.Config;
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Practices.ObjectBuilder2;
using Newtonsoft.Json;
using Org.BouncyCastle.Bcpg.OpenPgp;
using Pipelines.Sockets.Unofficial.Arenas;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web.Http;
using static Learun.Application.TwoDevelopment.ZZDT_EC.IO_WorkFlowService;

namespace Learun.Application.Web.AppApi
{
    /// <summary>
    /// IO模块（By YuXH）
    /// </summary>
    [HandlerApiLogin(FilterMode.Ignore)]
    public class IOModuleApiController : WebApiControllerBase
    {
        #region 模块对象
        private ec_CableBLL ec_CableBLL = new ec_CableBLL();

        private ec_PanelBLL ec_PanelBLL = new ec_PanelBLL();
        private ec_PanelStripBLL ec_PanelStripBLL = new ec_PanelStripBLL();
        private ec_PanelStripTermBLL ec_PanelStripTermBLL = new ec_PanelStripTermBLL();
        private ec_PanelChannelBLL ec_PanelChannelBLL = new ec_PanelChannelBLL();
        #endregion

        #region 信号相关



        #endregion





        /// <summary>
        /// IO分配主界面查询，查询所有的位置 - 采集箱 - 模块 - 通道
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public IHttpActionResult GetPanelTree(string projectId)
        { 

            //2023 05 22，从用户所在的role的lr base authorize里去查
            //UserInfo userInfo = LoginUserInfo.Get();
            //UserRelationIBLL userRelationIBLL = new UserRelationBLL();
            //var roles = userRelationIBLL.GetObjectIds(userInfo.userId, 1, projectId);
            var stopWatch = new Stopwatch();
            var Locations = GetLocList(projectId);
            if (Locations == null)
            {
                return Fail("系统设置中找不到“系统柜位置”这一项内容。联系管理员");
            }
            var ec_PanelStripTermService = new ec_PanelStripTermBLL();
            var ec_WireTerminalService = new ec_WireTerminalService();
            var ec_Wire_GroupService = new ec_Wire_GroupBLL();
            stopWatch.Start();
            var Panels = ec_PanelBLL.GetList("{ProjectId:\"" + projectId + "\"}").OrderBy(x => x.TagNumber).ToList();
            stopWatch.Stop();
            this.Logger.Info($"Panel查询 {stopWatch.ElapsedMilliseconds}" + "\r\n");
            stopWatch.Start();
            var Strips = ec_PanelStripBLL.GetList("{ProjectId:\"" + projectId + "\"}").OrderBy(x => x.Panel_Strip_Seq).OrderBy(x => x.StripName);
            stopWatch.Stop();
            this.Logger.Info($"Strip查询 {stopWatch.ElapsedMilliseconds}" + "\r\n");
            stopWatch.Start();
            var Channels = ec_PanelChannelBLL.GetList("{ProjectId:\"" + projectId + "\"}");
            stopWatch.Stop();
            this.Logger.Info($"Channel查询 {stopWatch.ElapsedMilliseconds}" + "\r\n");
            stopWatch.Start();
            var AllTerms = ec_PanelStripTermService.GetList("{ProjectId:\"" + projectId + "\"}");
            stopWatch.Stop();
            this.Logger.Info($"Term查询 {stopWatch.ElapsedMilliseconds}" + "\r\n");
            stopWatch.Start();
            var AllWTs = ec_WireTerminalService.GetList("{ProjectId:\"" + projectId + "\"}", true);
            stopWatch.Stop();
            this.Logger.Info($"WireTerminal查询 {stopWatch.ElapsedMilliseconds}" + "\r\n");
            stopWatch.Start();
            var AllSignals = ec_Wire_GroupService.GetList("{ProjectId:\"" + projectId + "\"}", true);
            stopWatch.Stop();
            this.Logger.Info($"Signals查询 {stopWatch.ElapsedMilliseconds}" + "\r\n");
            stopWatch.Start();
            List<TreeModel> treeList = new List<TreeModel>();
            foreach (var Loc in Locations)
            {
                TreeModel nodeCatalogue = new TreeModel();
                nodeCatalogue.id = Loc.DataItemDetailID;
                nodeCatalogue.text = Loc.DataItemName;
                nodeCatalogue.value = Loc.DataItemName;
                nodeCatalogue.nodeType = "0";
                nodeCatalogue.showcheck = false;
                nodeCatalogue.checkstate = 0;
                nodeCatalogue.isexpand = false;
                nodeCatalogue.parentId = Loc.UpDataItemDetailID;
                nodeCatalogue.NodeExtData = Loc;
                treeList.Add(nodeCatalogue);

                var listPanel = Panels.Where(x => x.Panel_Loc_ID == Loc.DataItemDetailID && x.systempanel == "1").ToList();
                if (listPanel != null && listPanel.Count > 0)
                {
                    foreach (var Panel in listPanel)
                    {
                        TreeModel nodeFile = new TreeModel();
                        nodeFile.id = Panel.PanelID;
                        nodeFile.text = Panel.TagNumber;
                        nodeFile.value = Panel.EngineerDataID;
                        nodeFile.nodeType = "1";
                        nodeFile.showcheck = false;
                        nodeFile.checkstate = 0;
                        nodeFile.isexpand = false;
                        nodeFile.parentId = Panel.Panel_Loc_ID; //后面会根据变为tree
                        nodeFile.NodeExtData = Panel;

                        //判断下是不是有效的类型

                        treeList.Add(nodeFile);

                        var StripsInPanel = Strips.Where(x => x.PanelID == Panel.PanelID).ToList();
                        if (StripsInPanel != null && StripsInPanel.Count > 0)
                        {
                            //StripsInPanel = StripsInPanel.OrderBy(x => x.Panel_Strip_Seq).ToList();
                            foreach (var Strip in StripsInPanel)
                            {
                                #region 带上汇总信息
                                var ChannelsInStrip = Channels.Where(x => x.StripID == Strip.StripID).ToList();//("{ProjectId:\"" + projectId + "\",StripID:\"" + Strip.StripID + "\",PanelID:\"" + Strip.PanelID + "\"}");
                                //Strip.Channels = ChannelsInStrip.ToList();
                                foreach (var Channel in ChannelsInStrip)
                                {
                                    var Terms = AllTerms.Where(x => x.StripID == Strip.StripID && x.ChannelID == Channel.ChannelID).ToList();//ec_PanelStripTermService.GetList("{ProjectId:\"" + projectId + "\",StripID:\"" + Strip.StripID + "\",ChannelID:\"" + Channel.ChannelID + "\"}");
                                    //wire termianl
                                    var conns = AllWTs.Where(x => Terms.Select(y => y.TermID).ToList().Contains(x.TermID)).ToList(); //.GetList(("{ProjectId:\"" + projectId + "\",PanelID:\"" + Strip.PanelID + "\",StripID:\"" + Strip.StripID + "\"}"));
                                    bool bUsed = false;

                                    if (conns != null && conns.Count() > 0)
                                    {
                                        bUsed = true;

                                    }
                                    //foreach (ec_PanelStripTermEntity term in Terms)
                                    //{
                                    //    var conn = conns.FirstOrDefault(x => x.TermID == term.TermID);
                                    //    if (conn != null)
                                    //    {
                                    //        bUsed = true;
                                    //        break;
                                    //    }

                                    //}
                                    if (bUsed)
                                    {
                                        //wire group
                                        var signal = AllSignals.FirstOrDefault(x => x.ChannelID == Channel.ChannelID);//.GetList("{ProjectId:\"" + projectId + "\",StripID:\"" + Strip.StripID + "\",ChannelID:\"" + Channel.ChannelID + "\"}").FirstOrDefault();
                                        if (signal != null)
                                        {
                                            Strip.ChannelsUsed += 1;
                                        }
                                        else
                                        {
                                            Strip.ChannelsUsedNoSignal += 1;
                                        }
                                    }
                                    else
                                    {
                                        Strip.ChannelsSpared += 1;
                                    }
                                }
                                #endregion

                                TreeModel nodeStrip = new TreeModel();
                                nodeStrip.id = Strip.StripID;
                                nodeStrip.text = Strip.StripName;
                                nodeStrip.value = Strip.Panel_Strip_Seq;
                                nodeStrip.nodeType = "1";
                                nodeStrip.showcheck = false;
                                nodeStrip.checkstate = 0;
                                nodeStrip.isexpand = false;
                                nodeStrip.parentId = Strip.PanelID;
                                nodeStrip.NodeExtData = Strip;

                                treeList.Add(nodeStrip);
                            }
                        }
                    }

                }

            }
            stopWatch.Stop();
            this.Logger.Info($"循环位置耗时 {stopWatch.ElapsedMilliseconds}" + "\r\n");
            return Success(treeList.ToTree());
        }

        /// <summary>
        /// 根据ID拿。只查询ec panel表本身
        /// </summary>
        /// <param name="PanelID"></param>
        /// <param name="projId"></param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetPanel(string PanelID, string projId)
        {
            var res = ec_PanelBLL.GetEntity(projId, PanelID);
            return Success(res);
        }

        /// <summary>
        /// 根据EngineerDataID拿。包括set wire，以及from to信息
        /// </summary>
        /// <param name="EngineerDataID"></param>
        /// <param name="projId"></param>
        /// <param name="OnlySelf"></param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetCableByEngID(string EngineerDataID, string projId, bool OnlySelf = false)
        {
            var res = ec_CableBLL.GetCableByEngID(projId, EngineerDataID, OnlySelf);
            return Success(res);
        }

        /// <summary>
        /// 查询所有的电缆
        /// </summary>
        /// <param name="projId"></param>
        /// <param name="homerun">true或false</param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetCables(string projId, bool homerun = true)
        {
            var res = ec_CableBLL.GetCables(projId, homerun);//这有个问题  如果一开始不知道要关联到那个通道 就不会有ec cable出来

            return Success(res);
        }
        /// <summary>
        /// PanelStrip参考库
        /// </summary>
        /// <param name="projId"></param>
        /// <param name="OnlySelf">false时，带上下面的通道和端子。true时，就是返回端子排自己</param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetPanelStrips(string projId, bool OnlySelf = false)
        {
            var res = ec_PanelStripBLL.GetList("{ProjectId:\"" + projId + "\",OnlySelf:\"" + OnlySelf + "\"}");
            return Success(res);
        }
        /// <summary>
        /// 在IO分配界面，从左侧目录树中选择一个“端子排”后，进行查询
        /// </summary>
        /// <param name="StripID"></param>
        /// <param name="projId"></param>
        /// <param name="OnlySelf">false时，带上下面的通道和端子。true时，就是返回端子排自己</param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetPanelStrip(string StripID, string projId, bool OnlySelf = false, bool HaveChannel = true)
        {
            var res = ec_PanelStripBLL.GetEntity(projId, StripID, OnlySelf, HaveChannel);
            return Success(res);
        }

        /// <summary>
        /// 新增或者修改。
        /// 新建相当于强行，因为正常流程是和engineerdata一起新建出来的。
        /// 改的话，只是改location和端子排数量这些。常规属性依旧通过objectTypeAPI去做
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="projId"></param>
        /// <returns></returns>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult SavePanel(ec_PanelEntity entity, string projId)
        {

            try
            {
                ec_PanelBLL.SaveEntity(projId, entity.PanelID, entity);
                return Success("OK");
            }
            catch (System.Exception E)
            {
                return Fail(E.Message);

            }
        }

        /// <summary>
        /// SaveConnections 专用
        /// </summary>
        private class Connections
        {
            public string ID { get; set; }
            public List<ec_WireTerminalEntity> Conns { get; set; }
        }


        /// <summary>
        /// 处理 接线关系，同时对cableset和wire的个别属性进行修改
        /// </summary> 
        /// <param name="projId"></param>
        /// <returns></returns>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult SaveConnections(string projId)
        {

            try
            {
                var asyncContent = Request.Content.ReadAsStringAsync().Result;
                var entity = asyncContent.ToObject<Connections>();
                var res = entity.Conns;
                new ec_WireTerminalBLL().SaveConnections(projId,ref res);
                return Success(res);
            }
            catch (System.Exception E)
            {
                return Fail(E.Message);

            }
        }



        /// <summary>
        /// 
        /// </summary> 
        /// <param name="projId"></param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetConnections(string projId, string ID)
        {

            try
            {
                var res = new ec_WireTerminalService().GetEntity(projId, ID);
                return Success(res);
            }
            catch (System.Exception E)
            {
                return Fail(E.Message);

            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="projId"></param>
        /// <returns></returns>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult SaveCable(ec_CableEntity entity, string projId)
        {

            try
            {
                if (!string.IsNullOrEmpty(entity.CableID))
                {
                    ec_CableBLL.SaveEntity(projId, entity.CableID, entity);
                }

                return Success("OK");
            }
            catch (System.Exception E)
            {
                return Fail(E.Message);

            }
        }
        /// <summary>
        /// 通过预设模式，批量创建端子排 通道 端子
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="projId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult CreatePanelStripByProfile(string projId)
        {
            try
            {
                var asyncContent = Request.Content.ReadAsStringAsync().Result;
                var entity = asyncContent.ToObject<ec_PanelStripEntity>();
                string NewID = "";
                ec_PanelStripBLL.SaveEntity(projId, "", entity, out NewID);

                var res = ec_PanelStripBLL.GetEntity(projId, NewID);
                return Success(res);
            }
            catch (System.Exception e)
            {
                return Fail(e.Message);
            }


        }




        /// <summary>
        /// 通过预设模式，批量创建端子排 端子
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="projId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult CreatePanelStripByProfileNoChannel(string projId, ec_PanelStripEntity entity)
        {
            try
            {
                string NewID = "";
                ec_PanelStripBLL.SaveEntity(projId, "", entity, out NewID, false);

                var res = ec_PanelStripBLL.GetEntity(projId, NewID);
                return Success(res);
            }
            catch (System.Exception e)
            {
                return Fail(e.Message);
            }


        }

        /// <summary>
        /// GetCableByEngID先去判断这个cable是否已经有了IO Module这边的记录
        /// 电缆-端子连接，从图面上选择一个电缆对象
        /// </summary>
        /// <param name="projId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult CreateCableByProfile(string projId)
        {
            try
            {
                var asyncContent = Request.Content.ReadAsStringAsync().Result;
                var entity = asyncContent.ToObject<ec_CableEntity>();

                ec_CableBLL.SaveEntity(projId, entity.CableID, entity);

                var res = ec_CableBLL.GetCableByEngID(projId, entity.EngineerDataID);
                return Success(res);
            }
            catch (System.Exception e)
            {
                return Fail(e.Message);
            }


        }
        /// <summary>
        /// 批量保存电缆的set wire 名字等
        /// </summary>
        /// <param name="projId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult SaveCables(string projId)
        {
            try
            {
                var asyncContent = Request.Content.ReadAsStringAsync().Result;
                var entitys = asyncContent.ToObject<List<ec_CableEntity>>();
                foreach (var entity in entitys)
                {
                    ec_CableBLL.SaveEntity(projId, entity.CableID, entity);

                }

                return Success(entitys);
            }
            catch (System.Exception e)
            {
                return Fail(e.Message);
            }


        }
        /// <summary>
        /// 保存端子排 通道 端子的信息（不管信号和接线关系）。
        /// 迁移通道也是这里。
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="projId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult SavePanelStrip(string projId, ec_PanelStripEntity entity)
        {
            XmlConfigurator.Configure();
            var log = log4net.LogManager.GetLogger("Debug"); //参数就是config里logger节点的名字
            try
            {
                //var asyncContent = Request.Content.ReadAsStringAsync().Result;
                //var entity = asyncContent.ToObject<ec_PanelStripEntity>();
                ec_PanelStripBLL.SaveEntity(projId, entity.StripID, entity, out string NewID);
                var res = ec_PanelStripBLL.GetEntity(projId, NewID);
                return Success(res);
            }
            catch (System.Exception e)
            {
                log.Debug($"★★★{DateTime.Now.ToString()}★★★{e}★★★");
                return Fail(e.Message);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="projId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult SavePanelStripTerm(ec_PanelStripTermEntity entity, string projId)
        {

            try
            {
                ec_PanelStripTermBLL.SaveEntity(projId, entity.TermID, entity);
                return Success("OK");
            }
            catch (System.Exception e)
            {
                return Fail(e.Message);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="projId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult SavePanelChannel(ec_PanelChannelEntity entity, string projId)
        {


            try
            {
                var newId = ec_PanelChannelBLL.SaveEntity(projId, entity.ChannelID, entity);
                foreach (var term in entity.Terms)
                {
                    ec_PanelStripTermBLL.SaveEntity(projId, term.TermID, term);
                }
                var res = ec_PanelChannelBLL.GetEntity(projId, newId);
                return Success(res);
            }
            catch (System.Exception e)
            {
                return Fail(e.Message);
            }
        }
        /// <summary>
        /// 调端子排所属Panel
        /// </summary>
        /// <param name="StripID">端子排ID</param>
        /// <param name="PanelID">PanelID</param>
        /// <param name="ProjectId">项目ID</param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult SwitchPanelStrip(string StripID, string PanelID, string ProjectId)
        {
            try
            {
                ec_PanelStripBLL.SwitchPanelStrip(StripID, PanelID, ProjectId);
                return Success("OK");
            }
            catch (System.Exception e)
            {
                return Fail(e.Message);
            }
        }
        /// <summary>
        /// 比如 移动通道时，进行保存
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="projId"></param>
        /// <returns></returns>
        [Obsolete]
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult SavePanelChannels(List<ec_PanelChannelEntity> entitys, string projId)
        {


            try
            {
                foreach (var entity in entitys)
                {
                    var newId = ec_PanelChannelBLL.SaveEntity(projId, entity.ChannelID, entity);
                    foreach (var term in entity.Terms)
                    {
                        ec_PanelStripTermBLL.SaveEntity(projId, term.TermID, term);
                    }
                }


                return Success("OK");
            }
            catch (System.Exception e)
            {
                return Fail(e.Message);
            }
        }


        /// <summary>
        /// 根据某个数据字典的编号来
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <returns></returns>
        private List<ec_dataitemdetailEntity> GetLocList(string ProjectId)
        {
            var ec_dataitemBLL = new ec_dataitemBLL();
            var settings = new ec_projectSettingsBLL();

            var ListFlg = settings.GetEntity("系统柜位置", ProjectId);

            if (ListFlg != null)
            {
                List<ec_dataitemdetailEntity> frameLists = new List<ec_dataitemdetailEntity>();
                frameLists.Add(new ec_dataitemdetailEntity() { DataItemName = "默认", DataItemCode = "默认", DataItemDetailID = "1", UpDataItemDetailID = "", DataItemID = "" });  //{ Name = "默认", Desc = "默认", Id = "1", ParentID = "" });
                var ListName = ec_dataitemBLL.GetList("{ProjectId:\"" + ProjectId + "\",keyword:\"" + ListFlg.SettingValue + "\"}").FirstOrDefault();
                if (ListName == null)
                {
                    return null;
                }
                else
                {
                    frameLists[0].DataItemID = ListName.DataItemID;
                }
                var res = ec_dataitemBLL.GetDetailList(ListFlg.SettingValue, "", ProjectId, false); //区域
                foreach (var item in res)
                {

                    //frameLists.Add(new ec_dataitemdetailEntity()
                    //{
                    //    Name = item.DataItemName,
                    //    ParentID = item.UpDataItemDetailID,
                    //    Desc = item.DataItemCode,
                    //    Id = item.DataItemDetailID,
                    //    DataItemId = item.DataItemID
                    //});
                    frameLists.Add(item);
                }


                return frameLists;
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 位置。缺省都放到“默认”下
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetLocationList(string ProjectId)
        {
            var RES = GetLocList(ProjectId);

            if (RES != null)
            {
                return Success(RES);
            }
            else
            {
                return Fail("未找到合适的数据字典，可以当做位置");
            }


        }

        /// <summary>
        /// 根据id来删除
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="ProjectId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult DeletePanel(string PanelID, string ProjectId)
        {
            new ec_enginedataBLL().DeleteEntity(PanelID, ProjectId);
            return Success("删除成功！");
        }
        /// <summary>
        /// 根据id来删除
        /// </summary>
        /// <param name="CableID"></param>
        /// <param name="ProjectId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult DeleteCableProfile(string CableID, string ProjectId)
        {
            ec_CableBLL.DeleteEntity(ProjectId, CableID);
            return Success("OK");
        }
        /// <summary>
        /// 根据id来删除
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="ProjectId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult DeletePanelStrip(string StripID, string ProjectId)
        {
            ec_PanelStripBLL.DeleteEntity(ProjectId, StripID);
            return Success("删除成功！");
        }

        /// <summary>
        /// 根据id来删除
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="ProjectId"></param>
        [HttpPost]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult DeletePanelChannel(string ChannelID, string ProjectId)
        {
            ec_PanelChannelBLL.DeleteEntity(ProjectId, ChannelID);
            return Success("OK");
        }
    }

    /// <summary>
    /// 
    /// </summary>
    //public class Panel_Location
    //{
    /// <summary>
    /// 
    /// </summary>
    //public string ParentID { get; set; }
    /// <summary>
    /// 
    /// </summary>
    //public string Id { set; get; }
    /// <summary>
    /// 所在数据字典的ID
    /// </summary>
    // public string DataItemId { set; get; }
    /// <summary>
    ///  
    /// </summary>
    //public string Name { get; set; }

    /// <summary>
    /// 数据字典里的code 
    /// </summary>
    //public string Desc { get; set; }
    //}


}